package com.xy.webadmin.app.model.userEmail;

import com.baomidou.mybatisplus.annotation.*;
import com.xy.webadmin.upms.model.SysDept;
import com.xy.webadmin.upms.model.SysUser;
import com.xy.application.common.constant.EmaiReceiveProtocol;
import com.xy.application.common.constant.YesOrNo;
import com.xy.common.core.annotation.*;
import lombok.Data;

import java.util.Date;
import java.util.Map;

/**
 * 用户邮箱配置实体对象。
 *
 * @author xiaoyue
 * @date 2025-05-13
 */
@Data
@TableName(value = "xy_user_email_config")
public class UserEmailConfig {

    /**
     * 主键。
     */
    @TableId(value = "id")
    private Long id;

    /**
     * 系统用户。
     */
    @UniqueVerifyField
    @UserFilterColumn
    @TableField(value = "sys_user_id")
    private Long sysUserId;

    /**
     * 邮箱。
     */
    @TableField(value = "email")
    private String email;

    /**
     * 收信协议。
     */
    @TableField(value = "receive_protocol")
    private Integer receiveProtocol;

    /**
     * 收信服务器。
     */
    @TableField(value = "receive_host")
    private String receiveHost;

    /**
     * 收信端口。
     */
    @TableField(value = "receive_port")
    private String receivePort;

    /**
     * 是否启用收信SSL加密。
     */
    @TableField(value = "receive_ssl")
    private Integer receiveSsl;

    /**
     * 发信服务器。
     */
    @TableField(value = "smtp_host")
    private String smtpHost;

    /**
     * 发信端口。
     */
    @TableField(value = "smtp_port")
    private Integer smtpPort;

    /**
     * 是否启用发信SSL加密。
     */
    @TableField(value = "smtp_ssl")
    private Integer smtpSsl;

    /**
     * 授权码。
     */
    @TableField(value = "auth_code")
    private String authCode;

    /**
     * 监听邮箱文件夹。
     */
    @TableField(value = "folder_name")
    private String folderName;

    /**
     * 最后监听时间。
     */
    @TableField(value = "last_sync_time")
    private Date lastSyncTime;

    /**
     * 是否开启监听模式。
     */
    @TableField(value = "is_active")
    private Integer isActive;

    /**
     * 公司。
     */
    @DeptFilterColumn
    @TableField(value = "company_id")
    private Long companyId;

    /**
     * 创建时间。
     */
    @TableField(value = "create_time")
    private Date createTime;

    /**
     * 更新时间。
     */
    @TableField(value = "update_time")
    private Date updateTime;

    /**
     * 创建者ID。
     */
    @TableField(value = "create_user_id")
    private Long createUserId;

    /**
     * 更新者ID。
     */
    @TableField(value = "update_user_id")
    private Long updateUserId;

    /**
     * 逻辑删除标记字段(0: 正常 1: 已删除)。
     */
    @TableLogic
    @TableField(value = "is_deleted")
    private Integer isDeleted;

    @RelationDict(
            masterIdField = "sysUserId",
            slaveModelClass = SysUser.class,
            slaveIdField = "userId",
            slaveNameField = "showName")
    @TableField(exist = false)
    private Map<String, Object> sysUserIdDictMap;

    @RelationDict(
            masterIdField = "companyId",
            slaveModelClass = SysDept.class,
            slaveIdField = "deptId",
            slaveNameField = "deptName")
    @TableField(exist = false)
    private Map<String, Object> companyIdDictMap;

    @RelationConstDict(
            masterIdField = "receiveProtocol",
            constantDictClass = EmaiReceiveProtocol.class)
    @TableField(exist = false)
    private Map<String, Object> receiveProtocolDictMap;

    @RelationConstDict(
            masterIdField = "receiveSsl",
            constantDictClass = YesOrNo.class)
    @TableField(exist = false)
    private Map<String, Object> receiveSslDictMap;

    @RelationConstDict(
            masterIdField = "smtpSsl",
            constantDictClass = YesOrNo.class)
    @TableField(exist = false)
    private Map<String, Object> smtpSslDictMap;

    @RelationConstDict(
            masterIdField = "isActive",
            constantDictClass = YesOrNo.class)
    @TableField(exist = false)
    private Map<String, Object> isActiveDictMap;
}
